package com.bohua.child.controller;

import com.bohua.child.common.Lay;
import com.bohua.child.common.Msg;
import com.bohua.child.entity.Teacher;
import com.bohua.child.service.TeacherService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
/**
 * 教师表控制器
 * @author shichenyang
 * @email gyv12345@163.com
 * @date 2019/01/17
 */
@Controller
@RequestMapping("/teacher")
public class TeacherController {
    @Resource
    private TeacherService teacherService;

    @RequestMapping
    public String teacher(){
        return "teacher/teacher.html";
    }
    @RequestMapping("/add")
    public String add(){
        return "teacher/addTeacher.html";
    }

    @RequestMapping("/update")
    public String update(){
        return "teacher/updateTeacher.html";
    }

    @RequestMapping("/getTeachers")
    @ResponseBody
    public Lay getTeachers(Teacher teacher,Integer page,Integer limit){
        return teacherService.getTeachers(teacher,page,limit);
    }
    @RequestMapping("/addTeacher")
    @ResponseBody
    public Msg addTeacher(Teacher teacher){
        return teacherService.addTeacher(teacher);
    }

    @RequestMapping("/updateTeacher")
    @ResponseBody
    public Msg updateTeacher(Teacher teacher){
        return teacherService.updateTeacher(teacher);
    }

    @RequestMapping("/delTeacher")
    @ResponseBody
    public Msg delTeacher(Teacher teacher){
        return teacherService.delTeacher(teacher);
    }
}
